#coding: utf-8 

from label import *
from simData import *

class Door():
	def __init__(self,name):
		self.name='d'+str(name)
		
		self.parent=None
		
		self.sum_x=0.
		self.sum_y=0.
		self.count_px=0.
		
		self.connected=False
		
		self.label=None
		self.update(False)
		
	def __repr__(self):
		text=str(self.name)#'Door: '+str(self.name)+str(self.pos)
		if not self.connected:
			text+=" not connected"
		return text
	
	def loadSprites(self,parent):
		self.parent=parent
		centerx,centery=self.parent.getPixelInScreen(self.pos)
		self.label=Label(text=str(self.name),centerx=centerx,centery=centery,color=(27,31,125))
	
	def update(self,visible):
		try:
			centerx,centery=self.parent.getPixelInScreen(self.pos)
			if visible and self.connected and DEBUG:
				self.label.update(text=str(self.name),centerx=centerx,centery=centery,color=(27,31,125))
			else:
				self.label.update(text='',centerx=centerx,centery=centery,color=(27,31,125))
		except:
			pass

